import FormCreater from '@/components/FormCreater';
import BasicForm from './components/BasicForm';
import PageHeader from '@/components/PageHeader';
import { submitForm } from '@/services/form';
import { Button, Card, Dialog, List, Message, ResponsiveGrid } from '@alifd/next';
import { definePageConfig, history, useSearchParams } from 'ice';
import { useEffect, useState } from 'react';
import dahai from 'common_library/dahai';

const { Cell } = ResponsiveGrid;
const project = dahai.createProject('decision', 'target_plan');
export default function FormBasic() {
  const [data, setData] = useState();
  useEffect(() => {
    project.getFileList().then(data => {
      setData(data);
    });;
  }, []);
  return (
    <ResponsiveGrid gap={20}>
      <Cell colSpan={12}>
        <PageHeader
          title="单列基础表单"
          description="单列基础表单描述信息"
          breadcrumbs={[{ name: '表单页面' }, { name: '单列基础表单' }]}
        />
      </Cell>

      <Cell colSpan={12}>
        <List
          size="small"
          dataSource={data}
          renderItem={(item: any, i) => (
            <List.Item
              extra={<Button onClick={(e) => {
                e.stopPropagation();
                Dialog.confirm({
                  title: '你确定要删除吗',
                  onOk: () => {
                    project.delFile(item.name).then(data => {
                      project.getFileList().then(data => {
                        setData(data);
                      });;
                    });;
                  }
                });
              }}>
                删除
              </Button>}
              key={i}
              // extra={item.money}
              title={item.name}
              // media={<Avatar src={item.img} />}
              onClick={() => {
                history?.push(`/target_detail/${item.name}/root`);
              }}
            >
            </List.Item>
          )}
        />

      </Cell>
    </ResponsiveGrid>
  );
}

export const pageConfig = definePageConfig(() => {
  return {
    auth: ['admin', 'user'],
    title: '行动列表',
  };
});
